package com.homework.demo1;

public class Student2 {
    private String name;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Student2() {
    }

    public Student2(String name) {
        this.name = name;
    }

    public String printName(Object greeting) throws MustStringArgumentException2 {
        if(!(greeting instanceof String)){
            throw new MustStringArgumentException2("传参必须为String类型");
        }
        String str = this.getName() + "," + greeting;
        return str;
    }

    public static void main(String[] args) {
        Student2 student = new Student2("张三");
        try {
            String s = student.printName("欢迎你");
            System.out.println(s);
            String s2 = student.printName(111);
            System.out.println(2);
        }catch (MustStringArgumentException2 mse){
            System.out.println("异常信息："+mse.getMessage());
        }

    }
}
